<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="../css/demo.css" />
    
    <title>Jslet - 图表对话框</title>
    <script type="text/javascript" data-main="../config.js" src="../lib/requirejs/require.min.js"></script>
    <script type="text/javascript">
	    require(['dialog/chartdialog']);
    </script>
</head>
<body>
    <div class="demo-header">
    <h4 id="top">Jslet - 图表对话框</h4>
	</div>
	<hr />
	<div class="container-fluid">
	<div class="form-horizontal">
	<div class="col-sm-12">
	    <button class="btn btn-default btn-sm" id="btnChart"> 图表分析 </button>
	</div>
	<div class="col-sm-12">
	<div data-jslet="type: 'DBTable', dataset: 'summary'" style="margin-bottom: 10px"></div>
	</div>
	
    </div>
    </div>
	<hr />
	<h4>源码</h4>
	<h5>HTML</h5>
    <pre class="prettyprint linenums"><code>
    &lt;div data-jslet="type: 'DBTable', dataset: 'summary'" style="margin-bottom: 10px">&lt;/div>
	</code></pre>
    
	<h5>JavaScript</h5>
    <pre class="prettyprint linenums"><code>
	//创建数据集
    var fldCfg = [
		{name: 'month', dataType: 'S', label: "Month"},
		{name: 'amount', dataType: 'N', label: "Amount", displayFormat: "#,##0.00"},
		{name: 'netprofit', dataType: 'N', label: "Net Profit", displayFormat: "#,##0.00"}
	];
    var dsSummary = new jslet.data.Dataset({name: "summary", fields: fldCfg});

    //创建演示数据
    var records = [{"month": "Jan.", "amount": 20000, "netprofit": 8000 },
        {"month": "Jan.", "amount": 30000, "netprofit": 11000 },
		{"month": "Feb.", "amount": 55500, "netprofit": 21000 },
		{"month": "Mar.", "amount": 45300, "netprofit": 14090 },
		{"month": "Apr.", "amount": 29300, "netprofit": 7409 },
		{"month": "May.", "amount": 49300, "netprofit": 12409 },
		{"month": "Jun.", "amount": 57900, "netprofit": 19900}
	];
    dsSummary.records(records);

    jslet.ui.install();
    
    //绑定按钮事件
	$('#btnChart').click(function() {
		var chartDlg = new jslet.ui.ChartDialog('summary', {categoryField: 'month'});
		chartDlg.show();
	});
	</code></pre>

    <script type="text/javascript">
       window.LOADER_BASE_URL = "../lib/prettify";
    </script>
    <script type="text/javascript" src="../lib/prettify/run_prettify.js"></script>
		
</body>
</html>
